
#!/bin/bash

# 表名数组
arr=(ads_alert_rule_efficiency ads_customer_risk_view ads_reg_compliance_monthly ads_transaction_risk_report)

sqoop_export_log="/root/aaa/program_2_hivesql/sqoop_export_log"

for i in "${arr[@]}"
do
    echo "开始导出表: $i"

    sqoop export \
    --connect jdbc:oracle:thin:@192.168.4.183:1521:orcl \
    --username SCOTT \
    --password 123456 \
    --table "$i" \
    --export-dir /user/hive/warehouse/ads.db/"$i" \
    --input-fields-terminated-by '\001' \
    --input-lines-terminated-by '\n' \
    --input-null-string '\\N' \
    --input-null-non-string '\\N' \
    -m 1

    # 检查上一个命令的状态
if [ $? -eq 0 ]; then
    echo "ADS → Oracle 导出完成 "
else
    echo "ADS → Oracle 导出失败 "
fi

echo "导出完成" >> $sqoop_export_log 2>&1

